<?
require_once('ConverterBase.php');

require_once('ri/filesys/UploadedFile.php');

class UploadedFileConverter extends ConverterBase {
	protected function toDatatype($string) {
		if (is_array($string)) {
			if ($string['error'])
				if ($string['error']=== 4) return null;
			else
				throw new ConverterException($this,'file_upload_error',$string['error']);
			return new UploadedFile($string['tmp_name'],$string['name']);
		}
		else return new UploadedFile($string,$string['name']);
	}
	protected function toString($object) {
		return $object->getLocation();
	}
}
